/*
 * Copyright (c) 2009, Jan Pastor. All Rights Reserved.
 */

package sk.jp.jitag.model.config;

import sk.jp.jitag.dao.db4o.BaseEntity;
import sk.jp.jitag.dao.db4o.Column;

/**
 * External tool.
 */
public class Tool extends BaseEntity implements Cloneable {

    private static final Column _LABEL = new Column("label");
    private static final Column _CMDLINE = new Column("cmdLine");

    private String label;
    private String cmdLine;
    private Integer action = null;

    //----------------------------------------------------------------------

    public Tool(String label, String cmdLine) {
        checkNotNullNotEmpty(_LABEL, label);
        checkMaxLen(_LABEL, label, 25);
        checkNotNullNotEmpty(_CMDLINE, cmdLine);
        checkMaxLen(_CMDLINE, label, 512);

        this.label = label;
        this.cmdLine = cmdLine;
    }

    //----------------------------------------------------------------------

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        checkNotNullNotEmpty(_LABEL, label);
        checkMaxLen(_LABEL, label, 25);

        this.label = label;
    }

    public String getCmdLine() {
        return cmdLine;
    }

    public void setCmdLine(String cmdLine) {
        checkNotNullNotEmpty(_CMDLINE, cmdLine);
        checkMaxLen(_CMDLINE, label, 512);

        this.cmdLine = cmdLine;
    }

    /**
     * @return action code or null if not specified.
     */
    public Integer getAction() {
        return action;
    }

    public void setAction(Integer action) {
        this.action = action;
    }

    @Override
    public String toString() {
        return "Tool{" +
               "label='" + label + '\'' +
               ", cmdLine='" + cmdLine + '\'' +
               ", action=" + action +
               '}';
    }
}
